package com.xinke.module.system.model.vo.auth;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Schema(description = "管理后台 - 登录用户的权限信息 Response VO，额外包括用户信息和角色列表")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AuthPermissionInfoRespVO {

    @Schema(description = "用户信息", requiredMode = Schema.RequiredMode.REQUIRED)
    private UserVO user;

    @Schema(description = "角色标识数组", requiredMode = Schema.RequiredMode.REQUIRED)
    private Set<String> roles;

    @Schema(description = "操作权限数组", requiredMode = Schema.RequiredMode.REQUIRED)
    private Set<String> permissions;

    @Schema(description = "菜单树", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<MenuVO> menus;

    @Schema(description = "用户信息 VO")
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class UserVO {

        @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
        private Long userId;

        @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
        private String userNickName;

        @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.jpg")
        private String userAvatar;

        @Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
        private Long deptId;

    }

    @Schema(description = "管理后台 - 登录用户的菜单信息 Response VO")
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class MenuVO {

        /*   @Schema(description = "菜单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
           private Long menuId;
   @Schema(description = "父菜单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
           private Long parentId;
           @Schema(description = "菜单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
           private String name;



           @Schema(description = "路由地址,仅菜单类型为菜单或者目录时，才需要传", example = "post")
           private String path;

           @Schema(description = "组件路径,仅菜单类型为菜单时，才需要传", example = "system/post/index")
           private String component;

           @Schema(description = "组件名", example = "SystemUser")
           private String componentName;

           @Schema(description = "菜单图标,仅菜单类型为菜单或者目录时，才需要传", example = "/menu/list")
           private String icon;

           @Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
           private Boolean visible;

           @Schema(description = "是否缓存", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
           private Boolean keepAlive;

           @Schema(description = "是否总是显示", example = "false")
           private Boolean alwaysShow;*/

        @Schema(description = "菜单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
        private Long menuId;
        @Schema(description = "父菜单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
        private Long parentId;

        @Schema(description = "组件名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "'Home'")
        private String name;
        // path: '/demos/access/page-control',
        @Schema(description = "组件路径", example = "/home")
        private String path;
        // component: () => import('#/views/demos/access/index.vue'),
        @Schema(description = "组件", example = "component: () => import('#/views/demos/access/index.vue')")
        private String component;

        @Schema(description = "重定向路径-父组件", example = "/home/index")
        private String redirect;
        @Schema(description = "路由元数据配置", example = "{}")
        private Meta meta = new Meta();
        /**
         * 子路由
         */
        private List<MenuVO> children;
    }

    @Schema(description = "管理后台 - 路由元数据配置(vben-admin对应的)")
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class Meta implements Serializable {
        private static final long serialVersionUID = 1L;

        /**
         * 激活图标（菜单）
         */
        private String activeIcon;

        /**
         * 当前激活的菜单，有时候不想激活现有菜单，需要激活父级菜单时使用
         */
        private String activePath;

        /**
         * 是否固定标签页
         */
        private Boolean affixTab = false;

        /**
         * 固定标签页的顺序
         */
        private Integer affixTabOrder = 0;

        /**
         * 需要特定的角色标识才可以访问
         */
        private List<String> authority;

        /**
         * 徽标
         */
        private String badge;

        /**
         * 徽标类型
         */
        private String badgeType; // "dot" 或 "normal"

        /**
         * 徽标颜色
         */
        private String badgeVariants; // "default", "destructive", "primary", "success", "warning" 或自定义

        /**
         * 当前路由的子级在菜单中不展现
         */
        private Boolean hideChildrenInMenu = false;

        /**
         * 当前路由在面包屑中不展现
         */
        private Boolean hideInBreadcrumb = false;

        /**
         * 当前路由在菜单中不展现
         */
        private Boolean hideInMenu = false;

        /**
         * 当前路由在标签页不展现
         */
        private Boolean hideInTab = false;

        /**
         * 图标（菜单/tab）
         */
        private String icon;

        /**
         * iframe 地址
         */
        private String iframeSrc;

        /**
         * 忽略权限，直接可以访问
         */
        private Boolean ignoreAccess = false;

        /**
         * 开启KeepAlive缓存
         */
        private Boolean keepAlive;

        /**
         * 外链-跳转路径
         */
        private String link;

        /**
         * 路由是否已经加载过
         */
        private Boolean loaded;

        /**
         * 标签页最大打开数量
         */
        private Integer maxNumOfOpenTab;

        /**
         * 菜单可以看到，但是访问会被重定向到403
         */
        private Boolean menuVisibleWithForbidden;

        /**
         * 当前路由不使用基础布局（仅在顶级生效）
         */
        private Boolean noBasicLayout;

        /**
         * 在新窗口打开
         */
        private Boolean openInNewWindow;

        /**
         * 用于路由->菜单排序
         */
        private Integer order;

        /**
         * 菜单所携带的参数
         */
        private Map<String, Object> query;

        /**
         * 标题名称
         */
        private String title;
    }
}
